package weibo4android.androidexamples;



import cn.com.karl.logic.MainService;
import weibo4android.androidexamples.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.TabActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.TextView;

public class MoreActivity extends Activity {
	private Button head_new;
	private Button head_refresh;
	private TextView head_userName;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
	    setContentView(R.layout.more);
		
	    head_new=(Button) this.findViewById(R.id.head_new);
		head_new.setVisibility(View.GONE);
		
		head_refresh=(Button) this.findViewById(R.id.head_refresh);
		head_refresh.setVisibility(View.GONE);
		
		head_userName=(TextView) this.findViewById(R.id.head_userName);
		head_userName.setText("更多");
	}
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
		
		if(keyCode==KeyEvent.KEYCODE_BACK){
			AlertDialog.Builder builder = new AlertDialog.Builder(this);
			builder.setMessage("你确定退出吗？")
			       .setCancelable(false)
			       .setPositiveButton("确定", new DialogInterface.OnClickListener() {
			           public void onClick(DialogInterface dialog, int id) {
			               MoreActivity.this.finish();
			               //停止服务
			               Intent it=new Intent(MoreActivity.this,MainService.class);
			                MoreActivity.this.stopService(it);
			               android.os.Process.killProcess(android.os.Process.myPid());
			               android.os.Process.killProcess(android.os.Process.myTid());
			               android.os.Process.killProcess(android.os.Process.myUid());
			              
			           }
			       })
			       .setNegativeButton("返回", new DialogInterface.OnClickListener() {
			           public void onClick(DialogInterface dialog, int id) {
			                dialog.cancel();
			           }
			       });
			AlertDialog alert = builder.create();
			alert.show();
			return true;
		}
		
		return super.onKeyDown(keyCode, event);
	}
	
}
